﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0064)http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html -->
<HTML><HEAD><TITLE>WPF性能校调 - Yzl的研究室 - 博客园</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="WPF SilverLight" name=keywords><LINK 
href="WPF性能校调 - Yzl的研究室 - 博客园.files/common.css" type=text/css 
rel=stylesheet><LINK id=MainCss href="WPF性能校调 - Yzl的研究室 - 博客园.files/style.css" 
type=text/css rel=stylesheet><LINK 
href="WPF性能校调 - Yzl的研究室 - 博客园.files/common2.css" type=text/css 
rel=stylesheet><LINK href="WPF性能校调 - Yzl的研究室 - 博客园.files/shCore.css" 
type=text/css rel=stylesheet><LINK 
href="WPF性能校调 - Yzl的研究室 - 博客园.files/shThemeDefault.css" type=text/css 
rel=stylesheet><LINK title=RSS href="http://www.cnblogs.com/yzlhccdec/rss" 
type=application/rss+xml rel=alternate><LINK title=RSD 
href="http://www.cnblogs.com/yzlhccdec/rsd.xml" type=application/rsd+xml 
rel=EditURI>
<SCRIPT src="WPF性能校调 - Yzl的研究室 - 博客园.files/jquery.js" 
type=text/javascript></SCRIPT>

<SCRIPT src="WPF性能校调 - Yzl的研究室 - 博客园.files/common.js" 
type=text/javascript></SCRIPT>

<SCRIPT src="WPF性能校调 - Yzl的研究室 - 博客园.files/jquery.json-1.3.min.js" 
type=text/javascript></SCRIPT>

<META content="MSHTML 6.00.2900.5897" name=GENERATOR></HEAD>
<BODY>
<FORM id=Form1 name=Form1 action=1114161.html method=post>
<DIV><INPUT id=__EVENTTARGET type=hidden name=__EVENTTARGET> <INPUT 
id=__EVENTARGUMENT type=hidden name=__EVENTARGUMENT> <INPUT 
id="&#13;&#10;__VIEWSTATE" type=hidden name=__VIEWSTATE> </DIV>
<SCRIPT type=text/javascript>
//<![CDATA[
var theForm = document.forms['Form1'];
if (!theForm) {
    theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</SCRIPT>

<TABLE class=banner height=250 cellSpacing=0 cellPadding=0 width="100%" 
background="WPF性能校调 - Yzl的研究室 - 博客园.files/bg_banner.jpg" border=0>
  <TBODY>
  <TR>
    <TD width=61>&nbsp;</TD>
    <TD align=middle width=236><BR><BR><BR><BR><BR><BR><BR>
      <DIV id=header><SPAN><A id=Header1_HeaderTitle 
      href="http://www.cnblogs.com/yzlhccdec/">Yzl的研究室</A><BR><BR>一切都是幻觉 
      </SPAN></DIV></TD>
    <TD style="PADDING-BOTTOM: 30px" vAlign=bottom align=middle>
      <DIV class=news>
      <DIV id=profile_block><A href="http://home.cnblogs.com/yzlhccdec/" 
      target=_blank>我的主页</A>&nbsp; <A 
      href="http://home.cnblogs.com/yzlhccdec/detail/" 
      target=_blank>个人资料</A><BR><A href="http://home.cnblogs.com/yzlhccdec/ing/" 
      target=_blank>我的闪存</A>&nbsp; <A 
      href="http://space.cnblogs.com/msg/send/yzlhccdec" 
      target=_blank>发短消息</A></DIV></DIV>&nbsp;</TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
  <TBODY>
  <TR>
    <TD width=60>&nbsp;</TD>
    <TD style="BORDER-RIGHT: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid" 
    vAlign=top width=100>
      <TABLE height=1400 cellSpacing=0 cellPadding=5 width="100%" align=center 
      bgColor=white border=0>
        <TBODY>
        <TR>
          <TD class=banner style="PADDING-TOP: 0px" vAlign=top>
            <SCRIPT type=text/javascript>
var blogapp = 'yzlhccdec';
</SCRIPT>

            <DIV class=mySearch>
            <H3 class=catListTitle>搜索</H3>
            <DIV class=div_my_zzk><INPUT class=input_my_zzk id=q 
            onkeydown="return zzk_go_enter(event);">&nbsp;<INPUT class=btn_my_zzk id=btnZzk onclick=zzk_go() type=button value=找找看></DIV></DIV>
            <DIV class=ad_side>
            <UL style="MARGIN-LEFT: 0px">
              <LI>
              <DIV>
              <SCRIPT type=text/javascript><!--
google_ad_client = "pub-4210569241504288";
/* cnblogs_博客侧边栏_180x150 */
google_ad_slot = "0808384890";
google_ad_width = 180;
google_ad_height = 150;
//-->
</SCRIPT>

              <SCRIPT src="WPF性能校调 - Yzl的研究室 - 博客园.files/show_ads.js" 
              type=text/javascript>
</SCRIPT>
              </DIV></LI></UL></DIV>
            <H3>常用链接</H3>
            <UL>
              <LI><A id=SingleColumn1_ctl03_rptMainLinks_ctl00_lnkLinkItem 
              href="http://www.cnblogs.com/yzlhccdec/MyPosts.html">我的随笔</A> 
              <LI><A id=SingleColumn1_ctl03_rptMainLinks_ctl01_lnkLinkItem 
              href="http://home.cnblogs.com/yzlhccdec/">我的空间</A> 
              <LI><A id=SingleColumn1_ctl03_rptMainLinks_ctl02_lnkLinkItem 
              href="http://space.cnblogs.com/msg/recent">我的短信</A> 
              <LI><A id=SingleColumn1_ctl03_rptMainLinks_ctl03_lnkLinkItem 
              href="http://www.cnblogs.com/yzlhccdec/MyComments.html">我的评论</A> 
              <LI><A id=itemListLink 
              onclick="this.blur();WarpClass('itemListLink', 'itemListLin_con');return false;" 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html#">更多链接</A> 
              </LI></UL>
            <DIV id=itemListLin_con style="DISPLAY: none">
            <UL>
              <LI><A id=SingleColumn1_ctl03_repeaterLinks_ctl01_lnkLinkItem 
              title=我发表过评论的随笔 
              href="http://www.cnblogs.com/yzlhccdec/OtherPosts.html">我的参与</A> 
              <LI><A id=SingleColumn1_ctl03_repeaterLinks_ctl02_lnkLinkItem 
              href="http://www.cnblogs.com/yzlhccdec/MyNews.html">我的新闻</A> 
              <LI><A id=SingleColumn1_ctl03_repeaterLinks_ctl03_lnkLinkItem 
              href="http://www.cnblogs.com/yzlhccdec/RecentComments.html">最新评论</A> 

              <LI><A id=SingleColumn1_ctl03_repeaterLinks_ctl04_lnkLinkItem 
              href="http://www.cnblogs.com/yzlhccdec/tag/">我的标签</A> 
            </LI></UL></DIV>
            <H3 class=catListTitle>我参与的团队</H3>
            <DIV class=RecentComment>
            <UL style="WORD-BREAK: break-all">
              <LI><A id=SingleColumn1__12bfd6e_TeamList_ctl01_lnkTeam 
              href="http://team.cnblogs.com/BJDotNetClub/">北京.NET俱乐部(0/0)</A> 
              </LI></UL></DIV>
            <H3 class=catListTitle>我的标签</H3>
            <DIV id=MyTag>
            <UL>
              <LI><A 
              href="http://www.cnblogs.com/yzlhccdec/tag/LINQ/">LINQ</A>(2)
              <LI><A 
              href="http://www.cnblogs.com/yzlhccdec/tag/å¤è¡¨æä½/">多表操作</A>(1)
              <LI><A 
              href="http://www.cnblogs.com/yzlhccdec/tag/åé¡µ/">分页</A>(1)
              <LI><A href="http://www.cnblogs.com/yzlhccdec/tag/ç®æ³+ACM/">算法 
              ACM</A>(1)
              <LI><A 
              href="http://www.cnblogs.com/yzlhccdec/tag/WPF+SilverLight/">WPF 
              SilverLight</A>(1)
              <LI><A 
              href="http://www.cnblogs.com/yzlhccdec/tag/Linq+Monorail/">Linq 
              Monorail</A>(1)
              <LI><A 
              href="http://www.cnblogs.com/yzlhccdec/tag/SilverLight/">SilverLight</A>(1)
              <LI><A href="http://www.cnblogs.com/yzlhccdec/tag/WPF/">WPF</A>(1)
              <LI><A 
              href="http://www.cnblogs.com/yzlhccdec/tag/Gzip/">Gzip</A>(1)
              <LI><A 
              href="http://www.cnblogs.com/yzlhccdec/tag/Ajax/">Ajax</A>(1)
              <LI><A href="http://www.cnblogs.com/yzlhccdec/tag/">更多</A> 
            </LI></UL></DIV>
            <H1 class=listtitle>随笔分类<SPAN 
            style="FONT-WEIGHT: normal; FONT-SIZE: 11px">(8)</SPAN></H1>
            <UL class=list>
              <LI class=listitem><A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl01_Link 
              href="http://www.cnblogs.com/yzlhccdec/category/125303.html">[.NET]LINQ 
              To SQL(4)</A> <A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl01_RssLink 
              title="Subscribe to [.NET]LINQ To SQL(4)" 
              href="http://www.cnblogs.com/yzlhccdec/category/125303.html/rss">(rss)</A> 

              <LI class=listitem><A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl02_Link 
              href="http://www.cnblogs.com/yzlhccdec/category/122151.html">[.NET]Performance 
              &amp;&amp; Optimization</A> <A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl02_RssLink 
              title="Subscribe to [.NET]Performance &amp;&amp; Optimization" 
              href="http://www.cnblogs.com/yzlhccdec/category/122151.html/rss">(rss)</A> 

              <LI class=listitem><A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl03_Link 
              href="http://www.cnblogs.com/yzlhccdec/category/127371.html">[.NET]WPF/SilverLight(2)</A> 
              <A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl03_RssLink 
              title="Subscribe to [.NET]WPF/SilverLight(2)" 
              href="http://www.cnblogs.com/yzlhccdec/category/127371.html/rss">(rss)</A> 

              <LI class=listitem><A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl04_Link 
              href="http://www.cnblogs.com/yzlhccdec/category/128093.html">[Web]Development(1)</A> 
              <A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl04_RssLink 
              title="Subscribe to [Web]Development(1)" 
              href="http://www.cnblogs.com/yzlhccdec/category/128093.html/rss">(rss)</A> 

              <LI class=listitem><A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl05_Link 
              href="http://www.cnblogs.com/yzlhccdec/category/126794.html">Data 
              Structures and Algorithms(1)</A> <A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl05_RssLink 
              title="Subscribe to Data Structures and Algorithms(1)" 
              href="http://www.cnblogs.com/yzlhccdec/category/126794.html/rss">(rss)</A> 

              <LI class=listitem><A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl06_Link 
              href="http://www.cnblogs.com/yzlhccdec/category/125302.html">SQL 
              Server</A> <A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl00_LinkList_ctl06_RssLink 
              title="Subscribe to SQL Server" 
              href="http://www.cnblogs.com/yzlhccdec/category/125302.html/rss">(rss)</A> 
              </LI></UL>
            <H1 class=listtitle>随笔档案<SPAN 
            style="FONT-WEIGHT: normal; FONT-SIZE: 11px">(13)</SPAN></H1>
            <UL class=list>
              <LI class=listitem><A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl01_LinkList_ctl01_Link 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/10.html">2008年10月 
              (1)</A> 
              <LI class=listitem><A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl01_LinkList_ctl02_Link 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/06.html">2008年6月 
              (2)</A> 
              <LI class=listitem><A class=listitem 
              id=SingleColumn1_Categories_CatList_ctl01_LinkList_ctl03_Link 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03.html">2008年3月 
              (10)</A> </LI></UL>
            <H3>积分与排名</H3>
            <UL>
              <LI>积分 - 42536 
              <LI>排名 - 1718 </LI></UL>
            <H3 class=catListTitle>最新评论 <A 
            id=SingleColumn1__49c25f_RSSHyperlink1 
            href="http://www.cnblogs.com/yzlhccdec/CommentsRSS.aspx"><IMG 
            style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/xml.gif"></A></H3>
            <DIV class=RecentComment id=RecentComments>
            <UL>
              <LI style="WORD-BREAK: break-all"><A 
              id=SingleColumn1__49c25f_CommentList_ctl01_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/06/1093750.html#1689078">1.&nbsp;Re:使用LINQ分页时需要注意的一个细节</A> 

              <LI style="WORD-BREAK: break-all">@fishren 应该是在实体属性上改，但是数据库那边不改 
              <LI style="MARGIN-RIGHT: 4px; TEXT-ALIGN: right">--Nickelzhang 
              <LI style="WORD-BREAK: break-all"><A 
              id=SingleColumn1__49c25f_CommentList_ctl02_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/06/1093750.html#1651730">2.&nbsp;Re:使用LINQ分页时需要注意的一个细节</A> 

              <LI style="WORD-BREAK: break-all">@无常能不能详细的说下怎么设置假主键 
              <LI style="MARGIN-RIGHT: 4px; TEXT-ALIGN: right">--fishren 
              <LI style="WORD-BREAK: break-all"><A 
              id=SingleColumn1__49c25f_CommentList_ctl03_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114009.html#1566425">3.&nbsp;re: 
              为WPF/SilverLight的学习者们打气</A> 
              <LI style="WORD-BREAK: break-all">欢迎加入 Silverlight WPF 超级群 
              13598877 <BR>本人和众多高手在线 
              <LI style="MARGIN-RIGHT: 4px; TEXT-ALIGN: right">--旻 
              <LI style="WORD-BREAK: break-all"><A 
              id=SingleColumn1__49c25f_CommentList_ctl04_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/24/1120259.html#1412902">4.&nbsp;re: 
              Ajax缓存问题</A> 
              <LI style="WORD-BREAK: break-all"><A 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/" 
              target=_new></A>
              <LI style="MARGIN-RIGHT: 4px; TEXT-ALIGN: right">--青羽 
              <LI style="WORD-BREAK: break-all"><A 
              id=SingleColumn1__49c25f_CommentList_ctl05_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/10/1099327.html#1374966">5.&nbsp;re: 
              使用LINQ进行多表操作(一)</A> 
              <LI style="WORD-BREAK: break-all">楼主的方法可以实现，但是我在分页码出现这个样的错误： 
              提供程序只支持对返回实体或投影(包含所有标识列)的有序查询使用 Skip()，这种查询为单表(非联接)查询，或者为 
              Distinct、Exce... 
              <LI style="MARGIN-RIGHT: 4px; TEXT-ALIGN: right">--jansky 
            </LI></UL></DIV>
            <H3 class=catListTitle>阅读排行榜</H3>
            <DIV class=RecentComment id=TopViewPosts>
            <UL style="WORD-BREAK: break-all">
              <LI><A id=SingleColumn1_ctl08_TopList_ctl01_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/13/1103023.html">1.&nbsp;关于三层架构的一些疑问(7852)</A> 

              <LI><A id=SingleColumn1_ctl08_TopList_ctl02_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/06/15/1222268.html">2.&nbsp;Resharper 
              4.0出来了(4294)</A> 
              <LI><A id=SingleColumn1_ctl08_TopList_ctl03_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114009.html">3.&nbsp;为WPF/SilverLight的学习者们打气(3761)</A> 

              <LI><A id=SingleColumn1_ctl08_TopList_ctl04_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/10/1099327.html">4.&nbsp;使用LINQ进行多表操作(一)(3423)</A> 

              <LI><A id=SingleColumn1_ctl08_TopList_ctl05_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/06/17/1223475.html">5.&nbsp;破解SQL 
              Prompt 3.8..(3010)</A> </LI></UL></DIV>
            <H3 class=catListTitle>评论排行榜</H3>
            <DIV class=RecentComment id=TopCommentsPosts>
            <UL style="WORD-BREAK: break-all">
              <LI><A id=SingleColumn1_ctl09_TopList_ctl01_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/13/1103023.html">1.&nbsp;关于三层架构的一些疑问(66)</A> 

              <LI><A id=SingleColumn1_ctl09_TopList_ctl02_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/06/15/1222268.html">2.&nbsp;Resharper 
              4.0出来了(38)</A> 
              <LI><A id=SingleColumn1_ctl09_TopList_ctl03_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/06/17/1223475.html">3.&nbsp;破解SQL 
              Prompt 3.8..(35)</A> 
              <LI><A id=SingleColumn1_ctl09_TopList_ctl04_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114009.html">4.&nbsp;为WPF/SilverLight的学习者们打气(26)</A> 

              <LI><A id=SingleColumn1_ctl09_TopList_ctl05_Hyperlink1 
              href="http://www.cnblogs.com/yzlhccdec/archive/2008/10/20/Use_NVelocity_In_ASPNET_MVC.html">5.&nbsp;在Asp.Net 
              MVC中使用NVelocity模板引擎（一）-自定义关键字(7)</A> </LI></UL></DIV><BR>
            <CENTER>Powered by: <A 
            href="http://www.cnblogs.com/">博客园</A><BR>模板提供：<A 
            href="http://blog.hjenglish.com/">沪江博客</A> 
      </CENTER></TD></TR></TBODY></TABLE></TD>
    <TD 
    style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px" 
    vAlign=top>
      <TABLE class=index height=1400 cellSpacing=0 cellPadding=5 width="100%" 
      align=center bgColor=white border=0>
        <TBODY>
        <TR>
          <TD class=banner vAlign=top>
            <CENTER><A class=menu id=MyLinks1_HomeLink 
            href="http://www.cnblogs.com/">博客园</A> | <A class=menu 
            id=MyLinks1_MyHomeLink 
            href="http://www.cnblogs.com/yzlhccdec/">首页</A> | <A class=menu 
            id=MyLinks1_NewPostLink 
            href="http://www.cnblogs.com/yzlhccdec/admin/EditPosts.aspx?opt=1">发新随笔</A> 
            | <A class=menu id=MyLinks1_NewArticleLink 
            href="http://www.cnblogs.com/EnterMyBlog.aspx?NewArticle=1">发新文章</A> 
            | <A class=menu id=MyLinks1_ContactLink accessKey=9 
            href="http://space.cnblogs.com/msg/send/yzlhccdec">联系</A> | <A 
            class=menu id=MyLinks1_Syndication 
            href="http://www.cnblogs.com/yzlhccdec/rss">订阅</A><A 
            id=MyLinks1_XMLLink href="http://www.cnblogs.com/yzlhccdec/rss"><IMG 
            style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" 
            alt=订阅 src="WPF性能校调 - Yzl的研究室 - 博客园.files/xml.gif"></A> | <A 
            class=menu id=MyLinks1_Admin 
            href="http://www.cnblogs.com/yzlhccdec/admin/EditPosts.aspx">管理</A> 
            </CENTER>
            <DIV class=block>
            <H1 class=block_title><A id=ctl03_TitleUrl 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html">WPF性能校调</A></H1>
            <DIV class=post>
            <DIV class=postcontent><SPAN 
            style="COLOR: red">声明：本文写于2007年4月8号，差不多一年前，之后我就没用过WPF了，不知道现在改了多少，麻烦大家自己筛选一下。</SPAN><BR>&nbsp; 

            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt">一、<STRONG>Rendering 
            Tier</STRONG></P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">1.<SPAN 
            style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            </SPAN><SPAN style="FONT-FAMILY: 宋体">根据硬件配置的不同，</SPAN>WPF<SPAN 
            style="FONT-FAMILY: 宋体">采用不同的</SPAN>Rendering Tier<SPAN 
            style="FONT-FAMILY: 宋体">做渲染。下列情况请特别注意，因为在这些情况下，即使是处于</SPAN>Rendering 
            Tier 2<SPAN style="FONT-FAMILY: 宋体">的情况下也不会硬件加速。</SPAN>(<SPAN 
            style="FONT-FAMILY: 宋体">不全，其余请查阅</SPAN>SDK)</P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: 0cm">Bitmap effects, 
            Printed content, Tiled content that uses TileBrush, Layered 
            windows.</P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: 0cm"><SPAN 
            style="FONT-FAMILY: 宋体">下列情况为</SPAN>Layered window: 1. WindowStyle = 
            none, 2.AllowsTransparency = true, 3.Background = Transparent.</P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt">二、<STRONG><SPAN 
            style="FONT-FAMILY: 宋体">布局和设计</SPAN></STRONG></P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: 0cm">1<SPAN 
            style="FONT-FAMILY: 宋体">．尽量多使用</SPAN>Canvas<SPAN 
            style="FONT-FAMILY: 宋体">等简单的布局元素，少使用</SPAN>Grid<SPAN 
            style="FONT-FAMILY: 宋体">或者</SPAN>StackPanel<SPAN 
            style="FONT-FAMILY: 宋体">等复杂的，越复杂性能开销越大。</SPAN></P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: 0cm">2<SPAN 
            style="FONT-FAMILY: 宋体">．建立逻辑树或者视觉树的时候，遵循</SPAN>Top-Down<SPAN 
            style="FONT-FAMILY: 宋体">的原则。示例代码如下：</SPAN></P>
            <TABLE style="WIDTH: 98.9%" cellSpacing=0 cellPadding=0 width="98%" 
            border=0>
              <TBODY>
              <TR>
                <TD 
                style="BORDER-RIGHT: medium none; PADDING-RIGHT: 4.2pt; BORDER-TOP: medium none; PADDING-LEFT: 4.2pt; BACKGROUND: #efeff7; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 0cm; BORDER-BOTTOM: #c8cdde 1pt solid" 
                vAlign=top>
                  <P style="MARGIN: 4.2pt 0cm; TEXT-ALIGN: left" 
                  align=left><STRONG><SPAN 
                  style="COLOR: #000066">C#&nbsp;</SPAN></STRONG></P></TD></TR>
              <TR>
                <TD 
                style="BORDER-RIGHT: medium none; PADDING-RIGHT: 4.2pt; BORDER-TOP: white 1pt solid; PADDING-LEFT: 4.2pt; BACKGROUND: #f7f7ff; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 4.2pt; BORDER-BOTTOM: #d5d5d3 1pt solid" 
                vAlign=top>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">private void 
                  OnBuildTreeTopDown(object sender, RoutedEventArgs 
e)</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">{</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  TextBlock textBlock = new TextBlock();</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  textBlock.Text = "Default";</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  DockPanel parentPanel = new DockPanel();</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  DockPanel childPanel;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  myCanvas.Children.Add(parentPanel);</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  myCanvas.Children.Add(textBlock);</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; for 
                  (int i = 0; i &lt; 150; i++)</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  {</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  textBlock = new TextBlock();</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  textBlock.Text = "Default";</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  parentPanel.Children.Add(textBlock);</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  childPanel = new DockPanel();</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  parentPanel.Children.Add(childPanel);</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                  parentPanel = childPanel;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  }</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
              style="COLOR: #000066">}</SPAN></P></TD></TR></TBODY></TABLE>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt">三、<STRONG><SPAN 
            style="FONT-FAMILY: 宋体">图像</SPAN></STRONG></P>
            <P style="MARGIN-LEFT: 23.25pt; TEXT-INDENT: -23.25pt">1．<SPAN 
            style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; 
            </SPAN><SPAN style="FONT-FAMILY: 宋体">对</SPAN>Image<SPAN 
            style="FONT-FAMILY: 宋体">做动画处理的时候（如调整大小等），可以使用这条语句</SPAN>RenderOptions.SetBitmapScalingMode(MyImage,BitmapScalingMode.LowQuality)<SPAN 
            style="FONT-FAMILY: 宋体">，以改善性能。</SPAN></P>
            <P style="MARGIN-LEFT: 23.25pt; TEXT-INDENT: -23.25pt">2．<SPAN 
            style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; 
            </SPAN><SPAN style="FONT-FAMILY: 宋体">用</SPAN>TileBrush<SPAN 
            style="FONT-FAMILY: 宋体">的时候，可以</SPAN>CachingHint<SPAN 
            style="FONT-FAMILY: 宋体">。</SPAN></P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt">四、<STRONG><SPAN 
            style="FONT-FAMILY: 宋体">对象行为</SPAN></STRONG></P>
            <P 
            style="MARGIN-LEFT: 21pt; TEXT-INDENT: 0cm"><STRONG>1</STRONG><STRONG><SPAN 
            style="FONT-FAMILY: 宋体">．</SPAN></STRONG><SPAN 
            style="FONT-FAMILY: 宋体">访问</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">对象和</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">属性的效率会比访问</SPAN>DependencyObject/DependencyProperty<SPAN 
            style="FONT-FAMILY: 宋体">高。注意这里指的是访问，不要和前面的绑定混淆了。但是，把属性注册为</SPAN>DependencyProperty<SPAN 
            style="FONT-FAMILY: 宋体">会有很多的优点：比如继承、数据绑定和</SPAN>Style<SPAN 
            style="FONT-FAMILY: 宋体">。所以有时候我们可以在实现</SPAN>DependencyProperty<SPAN 
            style="FONT-FAMILY: 宋体">的时候，利用缓存机制来加速访问速度：看下面的缓存例子：</SPAN></P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: 0cm"><SPAN 
            style="FONT-FAMILY: 宋体"></P>
            <DIV 
            style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" align=top><SPAN 
            style="COLOR: #0000ff">public</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">static</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">readonly</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;DependencyProperty&nbsp;MagicStringProperty&nbsp;</SPAN><SPAN 
            style="COLOR: #000000">=</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;DependencyProperty.Register(</SPAN><SPAN 
            style="COLOR: #800000">"</SPAN><SPAN 
            style="COLOR: #800000">MagicString</SPAN><SPAN 
            style="COLOR: #800000">"</SPAN><SPAN 
            style="COLOR: #000000">,&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">typeof</SPAN><SPAN 
            style="COLOR: #000000">(</SPAN><SPAN 
            style="COLOR: #0000ff">string</SPAN><SPAN 
            style="COLOR: #000000">),&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">typeof</SPAN><SPAN 
            style="COLOR: #000000">(MyButton),&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">new</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;PropertyMetadata(</SPAN><SPAN 
            style="COLOR: #0000ff">new</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;PropertyInvalidatedCallback(OnMagicStringPropertyInvalidated),</SPAN><SPAN 
            style="COLOR: #0000ff">new</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;GetValueOverride(MagicStringGetValueCallback)));<BR><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top>&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">private</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">static</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">void</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;OnMagicStringPropertyInvalidated(DependencyObject&nbsp;d)<BR><IMG 
            id=Codehighlighter1_362_430_Open_Image 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_362_430_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_362_430_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_362_430_Closed_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedBlockStart.gif" 
            align=top><IMG id=Codehighlighter1_362_430_Closed_Image 
            style="DISPLAY: none" 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_362_430_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_362_430_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_362_430_Open_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ContractedBlock.gif" 
            align=top>&nbsp;</SPAN><SPAN id=Codehighlighter1_362_430_Closed_Text 
            style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/dot.gif"></SPAN><SPAN 
            id=Codehighlighter1_362_430_Open_Text><SPAN 
            style="COLOR: #000000">{<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            style="COLOR: #008000">//</SPAN><SPAN 
            style="COLOR: #008000">&nbsp;将缓存的数据标识为无效</SPAN><SPAN 
            style="COLOR: #008000"><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top></SPAN><SPAN 
            style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;((MyButton)d)._magicStringValid&nbsp;</SPAN><SPAN 
            style="COLOR: #000000">=</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">false</SPAN><SPAN 
            style="COLOR: #000000">;<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedBlockEnd.gif" 
            align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top>&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">private</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">static</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">object</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;MagicStringGetValueCallback(DependencyObject&nbsp;d)<BR><IMG 
            id=Codehighlighter1_504_566_Open_Image 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_504_566_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_504_566_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_504_566_Closed_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedBlockStart.gif" 
            align=top><IMG id=Codehighlighter1_504_566_Closed_Image 
            style="DISPLAY: none" 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_504_566_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_504_566_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_504_566_Open_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ContractedBlock.gif" 
            align=top>&nbsp;</SPAN><SPAN id=Codehighlighter1_504_566_Closed_Text 
            style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/dot.gif"></SPAN><SPAN 
            id=Codehighlighter1_504_566_Open_Text><SPAN 
            style="COLOR: #000000">{<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            style="COLOR: #008000">//</SPAN><SPAN 
            style="COLOR: #008000">&nbsp;调用缓存的访问器来获取值</SPAN><SPAN 
            style="COLOR: #008000"><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top></SPAN><SPAN 
            style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">return</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;((MyButton)d).MagicString;<BR><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedBlockEnd.gif" 
            align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top>&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN 
            style="COLOR: #008000">&nbsp;私有的CLR访问器和本地缓存</SPAN><SPAN 
            style="COLOR: #008000"><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" align=top></SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">public</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">string</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;MagicString<BR><IMG 
            id=Codehighlighter1_615_904_Open_Image 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_615_904_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_615_904_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_615_904_Closed_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedBlockStart.gif" 
            align=top><IMG id=Codehighlighter1_615_904_Closed_Image 
            style="DISPLAY: none" 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_615_904_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_615_904_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_615_904_Open_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ContractedBlock.gif" 
            align=top>&nbsp;</SPAN><SPAN id=Codehighlighter1_615_904_Closed_Text 
            style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/dot.gif"></SPAN><SPAN 
            id=Codehighlighter1_615_904_Open_Text><SPAN 
            style="COLOR: #000000">{<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">get</SPAN><SPAN 
            style="COLOR: #000000"><BR><IMG 
            id=Codehighlighter1_629_837_Open_Image 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_629_837_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_629_837_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_629_837_Closed_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedSubBlockStart.gif" 
            align=top><IMG id=Codehighlighter1_629_837_Closed_Image 
            style="DISPLAY: none" 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_629_837_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_629_837_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_629_837_Open_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ContractedSubBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            id=Codehighlighter1_629_837_Closed_Text 
            style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/dot.gif"></SPAN><SPAN 
            id=Codehighlighter1_629_837_Open_Text><SPAN 
            style="COLOR: #000000">{<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            style="COLOR: #008000">//</SPAN><SPAN 
            style="COLOR: #008000">&nbsp;在当前值无效时，获取最新的值保存起来</SPAN><SPAN 
            style="COLOR: #008000"><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top></SPAN><SPAN 
            style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">if</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;(</SPAN><SPAN 
            style="COLOR: #000000">!</SPAN><SPAN 
            style="COLOR: #000000">_magicStringValid)<BR><IMG 
            id=Codehighlighter1_695_804_Open_Image 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_695_804_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_695_804_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_695_804_Closed_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedSubBlockStart.gif" 
            align=top><IMG id=Codehighlighter1_695_804_Closed_Image 
            style="DISPLAY: none" 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_695_804_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_695_804_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_695_804_Open_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ContractedSubBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            id=Codehighlighter1_695_804_Closed_Text 
            style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/dot.gif"></SPAN><SPAN 
            id=Codehighlighter1_695_804_Open_Text><SPAN 
            style="COLOR: #000000">{<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_magicString&nbsp;</SPAN><SPAN 
            style="COLOR: #000000">=</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;(</SPAN><SPAN 
            style="COLOR: #0000ff">string</SPAN><SPAN 
            style="COLOR: #000000">)GetValueBase(MagicStringProperty);<BR><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_magicStringValid&nbsp;</SPAN><SPAN 
            style="COLOR: #000000">=</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">true</SPAN><SPAN 
            style="COLOR: #000000">;<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedSubBlockEnd.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN 
            style="COLOR: #000000"><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">return</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;_magicString;<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedSubBlockEnd.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN 
            style="COLOR: #000000"><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">set</SPAN><SPAN 
            style="COLOR: #000000"><BR><IMG 
            id=Codehighlighter1_850_901_Open_Image 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_850_901_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_850_901_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_850_901_Closed_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedSubBlockStart.gif" 
            align=top><IMG id=Codehighlighter1_850_901_Closed_Image 
            style="DISPLAY: none" 
            onclick="this.style.display='none'; document.getElementById('Codehighlighter1_850_901_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_850_901_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_850_901_Open_Text').style.display='inline';" 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ContractedSubBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
            id=Codehighlighter1_850_901_Closed_Text 
            style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/dot.gif"></SPAN><SPAN 
            id=Codehighlighter1_850_901_Open_Text><SPAN 
            style="COLOR: #000000">{<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/InBlock.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetValue(MagicStringProperty,&nbsp;value);<BR><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedSubBlockEnd.gif" 
            align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN 
            style="COLOR: #000000"><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/ExpandedBlockEnd.gif" 
            align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top><BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top>&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">private</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">string</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;_magicString;<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top>&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">private</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;</SPAN><SPAN 
            style="COLOR: #0000ff">bool</SPAN><SPAN 
            style="COLOR: #000000">&nbsp;_magicStringValid;<BR><IMG alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" align=top><BR><IMG 
            alt="" src="WPF性能校调 - Yzl的研究室 - 博客园.files/None.gif" 
            align=top></SPAN></DIV>
            <P 
            style="MARGIN-LEFT: 21pt; TEXT-INDENT: 0cm"><BR>另外，因为注册的</SPAN>DependencyProperty<SPAN 
            style="FONT-FAMILY: 宋体">在默认是不可继承的，如果需要继承特性，也会降低</SPAN>DependencyProperty<SPAN 
            style="FONT-FAMILY: 宋体">值刷新的效率。注册</SPAN>DependencyProperty<SPAN 
            style="FONT-FAMILY: 宋体">属性时，应该把</SPAN>DefaultValue<SPAN 
            style="FONT-FAMILY: 宋体">传递给</SPAN>Register<SPAN 
            style="FONT-FAMILY: 宋体">方法的参数来实现默认值的设置，而不是在构造函数中设置。</SPAN></P>
            <P 
            style="MARGIN-LEFT: 21pt; TEXT-INDENT: 0cm"><STRONG></STRONG>&nbsp;</P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt">五、<STRONG><SPAN 
            style="FONT-FAMILY: 宋体">应用程序资源</SPAN></STRONG></P>
            <P style="MARGIN-LEFT: 39.3pt; TEXT-INDENT: -18pt">1．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">在自定义控件，尽量不要在控件的</SPAN>ResourceDictionary<SPAN 
            style="FONT-FAMILY: 宋体">定义资源，而应该放在</SPAN>Window<SPAN 
            style="FONT-FAMILY: 宋体">或者</SPAN>Application<SPAN 
            style="FONT-FAMILY: 宋体">级。因为放在控件中会使每个实例都保留一份资源的拷贝。</SPAN></P>
            <P style="MARGIN-LEFT: 39.3pt; TEXT-INDENT: -18pt">2．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">尽量使用</SPAN>Static Resources,<SPAN 
            style="FONT-FAMILY: 宋体">但不能盲目使用。</SPAN></P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt">六、<STRONG><SPAN 
            style="FONT-FAMILY: 宋体">文本</SPAN></STRONG></P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">1．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">文字少的时候用</SPAN>TextBlock<SPAN 
            style="FONT-FAMILY: 宋体">或者</SPAN>label,<SPAN 
            style="FONT-FAMILY: 宋体">长的时候用</SPAN>FlowDocument.</P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">2．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">使用元素</SPAN>TextFlow<SPAN 
            style="FONT-FAMILY: 宋体">和</SPAN>TextBlock<SPAN 
            style="FONT-FAMILY: 宋体">时，如果不需要</SPAN>TextFlow<SPAN 
            style="FONT-FAMILY: 宋体">的某些特性，就应该考虑使用</SPAN>TextBlock<SPAN 
            style="FONT-FAMILY: 宋体">，因为它的效率更高。</SPAN></P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">3．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">在</SPAN>TextFlow<SPAN 
            style="FONT-FAMILY: 宋体">中使用</SPAN>UIElement<SPAN 
            style="FONT-FAMILY: 宋体">（比如</SPAN>TextBlock<SPAN 
            style="FONT-FAMILY: 宋体">）所需的代价要比使用</SPAN>TextElement<SPAN 
            style="FONT-FAMILY: 宋体">（比如</SPAN>Run<SPAN 
            style="FONT-FAMILY: 宋体">）的代价高</SPAN>.<SPAN 
            style="FONT-FAMILY: 宋体">在</SPAN>FlowDocument<SPAN 
            style="FONT-FAMILY: 宋体">中尽量避免使用</SPAN>TextBlock<SPAN 
            style="FONT-FAMILY: 宋体">，要用</SPAN>Run<SPAN 
            style="FONT-FAMILY: 宋体">替代。代码如下：</SPAN></P>
            <TABLE style="WIDTH: 98.9%" cellSpacing=0 cellPadding=0 width="98%" 
            border=0>
              <TBODY>
              <TR>
                <TD 
                style="BORDER-RIGHT: medium none; PADDING-RIGHT: 4.2pt; BORDER-TOP: white 1pt solid; PADDING-LEFT: 4.2pt; BACKGROUND: #f7f7ff; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 4.2pt; BORDER-BOTTOM: #d5d5d3 1pt solid" 
                vAlign=top colSpan=2>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&lt;FlowDocument&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&lt;!-- Text 
                  content within a Run (more efficient). --&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&lt;Paragraph&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  &lt;Run&gt;Line one&lt;/Run&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&lt;/Paragraph&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&lt;!-- Text 
                  content within a TextBlock (less efficient). --&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&lt;Paragraph&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&nbsp;&nbsp; 
                  &lt;TextBlock&gt;Line two&lt;/TextBlock&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&nbsp;&lt;/Paragraph&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&lt;/FlowDocument&gt;</SPAN></P></TD></TR></TBODY></TABLE>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">4．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">在</SPAN>TextBlock<SPAN 
            style="FONT-FAMILY: 宋体">中显式的使用</SPAN>Run<SPAN 
            style="FONT-FAMILY: 宋体">命令比不使用</SPAN>Run<SPAN 
            style="FONT-FAMILY: 宋体">命名的代码要高。</SPAN></P>
            <TABLE style="WIDTH: 98.9%" cellSpacing=0 cellPadding=0 width="98%" 
            border=0>
              <TBODY>
              <TR>
                <TD 
                style="BORDER-RIGHT: medium none; PADDING-RIGHT: 4.2pt; BORDER-TOP: white 1pt solid; PADDING-LEFT: 4.2pt; BACKGROUND: #f7f7ff; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 4.2pt; BORDER-BOTTOM: #d5d5d3 1pt solid" 
                vAlign=top colSpan=2>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&lt;!-- Run is used to 
                  set text properties. --&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&lt;TextBlock&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&lt;Run 
                  FontWeight="Bold"&gt;Hello, world&lt;/Run&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&lt;/TextBlock&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&lt;!-- TextBlock is 
                  used to set text properties, which is more efficient. 
                  --&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&lt;TextBlock 
                  FontWeight="Bold"&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;Hello, 
                  world</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&lt;/TextBlock&gt;</SPAN></P></TD></TR></TBODY></TABLE>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">5．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">把</SPAN>Label<SPAN 
            style="FONT-FAMILY: 宋体">（标签）元素的</SPAN>ContentProperty<SPAN 
            style="FONT-FAMILY: 宋体">和一个字符串（</SPAN>String<SPAN 
            style="FONT-FAMILY: 宋体">）绑定的效率要比把字符串和</SPAN>TextBlock<SPAN 
            style="FONT-FAMILY: 宋体">的</SPAN>Text<SPAN 
            style="FONT-FAMILY: 宋体">属性绑定的效率低。因为</SPAN>Label<SPAN 
            style="FONT-FAMILY: 宋体">在更新字符串是会丢弃原来的字符串，全部重新显示内容。如果字符串不需要更新，用</SPAN>Label<SPAN 
            style="FONT-FAMILY: 宋体">就无所谓性能问题。</SPAN></P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">6．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">在</SPAN>TextBlock<SPAN 
            style="FONT-FAMILY: 宋体">块使用</SPAN>HyperLinks<SPAN 
            style="FONT-FAMILY: 宋体">时，把多个</SPAN>HyperLinks<SPAN 
            style="FONT-FAMILY: 宋体">组合在一起效率会更高。</SPAN></P>
            <TABLE style="WIDTH: 100%" cellSpacing=0 cellPadding=0 width="100%" 
            border=0>
              <TBODY>
              <TR>
                <TD 
                style="BORDER-RIGHT: medium none; PADDING-RIGHT: 4.2pt; BORDER-TOP: white 1pt solid; PADDING-LEFT: 4.2pt; BACKGROUND: #f7f7ff; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 4.2pt; BORDER-BOTTOM: #d5d5d3 1pt solid" 
                vAlign=top colSpan=2>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&lt;!-- Hyperlinks in 
                  separate TextBlocks. --&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&lt;TextBlock&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&lt;Hyperlink 
                  TextDecorations="None" NavigateUri="http://www.msn.com"&gt;MSN 
                  Home&lt;/Hyperlink&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&lt;/TextBlock&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&lt;TextBlock Text=" | 
                  "/&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&lt;TextBlock&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN style="COLOR: #000066">&nbsp;&lt;Hyperlink 
                  TextDecorations="None" NavigateUri="http://my.msn.com"&gt;My 
                  MSN&lt;/Hyperlink&gt;</SPAN></P>
                  <P 
                  style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                  align=left><SPAN 
                  style="COLOR: #000066">&lt;/TextBlock&gt;</SPAN></P></TD></TR>
              <TR>
                <TD 
                style="BORDER-RIGHT: medium none; PADDING-RIGHT: 4.2pt; BORDER-TOP: white 1pt solid; PADDING-LEFT: 4.2pt; BACKGROUND: #f7f7ff; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 4.2pt; BORDER-BOTTOM: #d5d5d3 1pt solid" 
                vAlign=top colSpan=2>
                  <TABLE style="WIDTH: 98.9%" cellSpacing=0 cellPadding=0 
                  width="98%" border=0>
                    <TBODY>
                    <TR>
                      <TD 
                      style="BORDER-RIGHT: medium none; PADDING-RIGHT: 4.2pt; BORDER-TOP: white 1pt solid; PADDING-LEFT: 4.2pt; BACKGROUND: #f7f7ff; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 4.2pt; BORDER-BOTTOM: #d5d5d3 1pt solid" 
                      vAlign=top colSpan=2>
                        <P 
                        style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                        align=left><SPAN style="COLOR: #000066">&lt;!-- 
                        Hyperlinks combined in the same TextBlock. 
                        --&gt;</SPAN></P>
                        <P 
                        style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                        align=left><SPAN 
                        style="COLOR: #000066">&lt;TextBlock&gt;</SPAN></P>
                        <P 
                        style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                        align=left><SPAN 
                        style="COLOR: #000066">&nbsp;&lt;Hyperlink 
                        TextDecorations="None" 
                        NavigateUri="http://www.msn.com"&gt;MSN 
                        Home&lt;/Hyperlink&gt;</SPAN></P>
                        <P 
                        style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                        align=left><SPAN 
style="COLOR: #000066"></SPAN>&nbsp;</P>
                        <P 
                        style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                        align=left><SPAN style="COLOR: #000066">&nbsp;&lt;Run 
                        Text=" | " /&gt;</SPAN></P>
                        <P 
                        style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                        align=left><SPAN 
style="COLOR: #000066"></SPAN>&nbsp;</P>
                        <P 
                        style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                        align=left><SPAN 
                        style="COLOR: #000066">&nbsp;&lt;Hyperlink 
                        TextDecorations="None" 
                        NavigateUri="http://my.msn.com"&gt;My 
                        MSN&lt;/Hyperlink&gt;</SPAN></P>
                        <P 
                        style="MARGIN: 0cm 0.85pt 0pt; TEXT-ALIGN: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" 
                        align=left><SPAN 
                        style="COLOR: #000066">&lt;/TextBlock&gt;</SPAN></P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">7．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">显示超链接的时候，尽量只在</SPAN>IsMouseOver<SPAN 
            style="FONT-FAMILY: 宋体">为</SPAN>True<SPAN 
            style="FONT-FAMILY: 宋体">的时候显示下划线，一直显示下划线的代码高很多</SPAN></P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">8．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">尽量不使用不必要的字符串连接。</SPAN></P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt">七、<STRONG><SPAN 
            style="FONT-FAMILY: 宋体">数据绑定</SPAN></STRONG></P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: 0cm">1<SPAN 
            style="FONT-FAMILY: 宋体">．在使用数据绑定的过程中，如果绑定的数据源是一个</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">对象，属性也是一个</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">属性，那么在绑定的时候对象</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">对象所实现的机制不同，绑定的效率也不同。</SPAN></P>
            <P style="MARGIN-LEFT: 21pt">A<SPAN 
            style="FONT-FAMILY: 宋体">、数据源是一个</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">对象，属性也是一个</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">属性。对象通过</SPAN>TypeDescriptor/PropertyChanged<SPAN 
            style="FONT-FAMILY: 宋体">模式实现通知功能。此时绑定引擎用</SPAN>TypeDescriptor<SPAN 
            style="FONT-FAMILY: 宋体">来反射源对象。效率最低。</SPAN></P>
            <P style="MARGIN-LEFT: 21pt">B<SPAN 
            style="FONT-FAMILY: 宋体">、数据源是一个</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">对象，属性也是一个</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">属性。对象通过</SPAN>INotifyPropertyChanged<SPAN 
            style="FONT-FAMILY: 宋体">实现通知功能。此时绑定引擎直接反射源对象。效率稍微提高。</SPAN></P>
            <P style="MARGIN-LEFT: 21pt">C<SPAN 
            style="FONT-FAMILY: 宋体">、数据源是一个</SPAN>DependencyObject<SPAN 
            style="FONT-FAMILY: 宋体">，而且属性是一个</SPAN>DependencyProperty<SPAN 
            style="FONT-FAMILY: 宋体">。此时不需要反射，直接绑定。效率最高。</SPAN></P>
            <P style="MARGIN-LEFT: 21.3pt">2<SPAN 
            style="FONT-FAMILY: 宋体">．当一个</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">对象很大时，比如有</SPAN>1000<SPAN 
            style="FONT-FAMILY: 宋体">个属性时，尽量把这个对象分解成很多很小的</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">对象。比如分成</SPAN>1000<SPAN 
            style="FONT-FAMILY: 宋体">个只有一个属性的</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">对象。</SPAN></P>
            <P style="MARGIN-LEFT: 39.3pt; TEXT-INDENT: -18pt">3．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">当我们在列表（比如</SPAN>ListBox<SPAN 
            style="FONT-FAMILY: 宋体">）显示了一个</SPAN>CLR<SPAN 
            style="FONT-FAMILY: 宋体">对象列表（比如</SPAN>List<SPAN 
            style="FONT-FAMILY: 宋体">）时，如果想在修改</SPAN>List<SPAN 
            style="FONT-FAMILY: 宋体">对象后，</SPAN>ListBox<SPAN 
            style="FONT-FAMILY: 宋体">也动态的反映这种变化。此时，我们应该使用动态的</SPAN>ObservableCollection<SPAN 
            style="FONT-FAMILY: 宋体">对象绑定。而不是直接的更新</SPAN>ItemSource<SPAN 
            style="FONT-FAMILY: 宋体">。两者的区别在于直接更新</SPAN>ItemSource<SPAN 
            style="FONT-FAMILY: 宋体">会使</SPAN>WPF<SPAN 
            style="FONT-FAMILY: 宋体">抛弃</SPAN>ListBox<SPAN 
            style="FONT-FAMILY: 宋体">已有的所有数据，然后全部重新从</SPAN>List<SPAN 
            style="FONT-FAMILY: 宋体">加载。而使用</SPAN>ObservableCollection<SPAN 
            style="FONT-FAMILY: 宋体">可以避免这种先全部删除再重载的过程，效率更高。</SPAN></P>
            <P style="MARGIN-LEFT: 39.3pt; TEXT-INDENT: -18pt">4．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">尽量绑定</SPAN>IList<SPAN 
            style="FONT-FAMILY: 宋体">而不是</SPAN>IEnumerable<SPAN 
            style="FONT-FAMILY: 宋体">到</SPAN>ItemsControl<SPAN 
            style="FONT-FAMILY: 宋体">。</SPAN></P>
            <P style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt">八、<STRONG><SPAN 
            style="FONT-FAMILY: 宋体">其它性能建议</SPAN></STRONG></P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">1．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">如果需要修改元素的</SPAN>Opacity<SPAN 
            style="FONT-FAMILY: 宋体">属性，最后修改一个</SPAN>Brush<SPAN 
            style="FONT-FAMILY: 宋体">的属性，然后用这个</SPAN>Brush<SPAN 
            style="FONT-FAMILY: 宋体">来填充元素。因为直接修改元素的</SPAN>Opacity<SPAN 
            style="FONT-FAMILY: 宋体">会迫使系统创建一个临时的</SPAN>Surface</P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">2．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">用</SPAN>NavigationWindow<SPAN 
            style="FONT-FAMILY: 宋体">的时候，尽量</SPAN>Update the client area by 
            object,<SPAN style="FONT-FAMILY: 宋体">而不是</SPAN>URI</P>
            <P style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt">3．&nbsp;<SPAN 
            style="FONT-FAMILY: 宋体">尽量不要使用</SPAN>ScrollBarVisibility=Auto </P>
            <DIV id=EntryTag>Tag标签: <A 
            href="http://www.cnblogs.com/yzlhccdec/tag/WPF+SilverLight/">WPF 
            SilverLight</A></DIV>
            <DIV id=digg_block>
            <DIV id=div_digg>
            <DIV class=diggit onclick=DiggIt(1114161,33444,1)><SPAN 
            class=diggnum id=digg_count_1114161>0</SPAN> </DIV>
            <DIV class=buryit onclick=DiggIt(1114161,33444,2)><SPAN 
            class=burynum id=bury_count_1114161>0</SPAN> </DIV>
            <DIV class=clear></DIV><SPAN id=span_isdigged_1114161 
            style="DISPLAY: none">0</SPAN> 
            <DIV class=diggword 
            id=digg_word_1114161>(请您对文章做出评价)</DIV></DIV></DIV>
            <DIV class=clear></DIV>
            <DIV id=post_next_prev><A 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114009.html">« 
            </A>上一篇：<A title="发布于2008-03-20 01:47" 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114009.html">为WPF/SilverLight的学习者们打气</A><BR><A 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/21/1116725.html">» 
            </A>下一篇：<A title="发布于2008-03-21 16:52" 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/21/1116725.html">MonoRail和Linq 
            To SQL的兼容性问题</A><BR></DIV>
            <SCRIPT src="WPF性能校调 - Yzl的研究室 - 博客园.files/google_service.js" 
            type=text/javascript></SCRIPT>

            <SCRIPT type=text/javascript>
    try {
        GS_googleAddAdSenseService("ca-pub-4210569241504288");
        GS_googleEnableAllServices();
    }
    catch (e) { }
</SCRIPT>

            <SCRIPT type=text/javascript>
    try {
        GA_googleAddSlot("ca-pub-4210569241504288", "cnblogs_blogpost_body");
        GA_googleAddSlot("ca-pub-4210569241504288", "cnblogs_commentbox_up");
        GA_googleAddSlot("ca-pub-4210569241504288", "cnblogs_blogpost_bottom");
    }
    catch (e) { }
</SCRIPT>

            <SCRIPT type=text/javascript>
    try {
        GA_googleFetchAds();
    } catch (e) { }
</SCRIPT>

            <SCRIPT type=text/javascript>
    var blog_ad_has_shown = false;
</SCRIPT>

            <DIV id=post_body_ad style="MARGIN-TOP: 5px">
            <SCRIPT type=text/javascript> try { GA_googleFillSlot("cnblogs_blogpost_body");}catch (e) { } 
 blog_ad_has_shown=true;</SCRIPT>
            </DIV></DIV>
            <DIV class=itemdesc>发表于 2008-03-20 09:23 <A 
            href="http://www.cnblogs.com/yzlhccdec/">yzlhccdec</A> 阅读(2455) <A 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html#commentform">评论(1)</A> 
            &nbsp;<A 
            href="http://www.cnblogs.com/yzlhccdec/admin/EditPosts.aspx?postid=1114161">编辑</A> 
            <A 
            href="http://www.cnblogs.com/yzlhccdec/AddToFavorite.aspx?id=1114161">收藏</A> 
            <A onclick="PutInWz();return false;" 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html#">网摘</A> 
            所属分类: <A 
            href="http://www.cnblogs.com/yzlhccdec/category/127371.html">[.NET]WPF/SilverLight</A> 
            </DIV></DIV>
            <DIV class=seperator>&nbsp;</DIV><IMG height=1 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/1114161.jpg" width=1> <!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description
rdf:about="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html"
dc:identifier="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html"
dc:title=""
trackback:ping="http://www.cnblogs.com/yzlhccdec/services/trackbacks/1114161.aspx" />
</rdf:RDF>
--><A name=pagedcomment></A>
            <DIV class=post><A name=评论>
            <DIV class=moreinfo>
            <DIV class=moreinfotitle>评论 </DIV><SPAN id=span_comment_maxid 
            style="DISPLAY: none">1115763</SPAN> 
            <DIV class=comments>
            <DIV class=comment>
            <DIV class=comment_title><A 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html#1115763">#1楼</A><A 
            id=comment_anchor_1115763 name=1115763></A><A 
            name=Post></A>&nbsp;&nbsp;&nbsp;&nbsp;<A 
            onclick='ReplyComment("一瞬间",1115763,"1BnHFHZQbFGj2AQJ0gdQkS8Dcy+803WCbuZQxZkHJabtzyY7oJzCuA==")' 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html#commentform">回复</A>&nbsp;&nbsp;<A 
            onclick='QuoteComment(1115763,"1BnHFHZQbFGj2AQJ0gdQkS8Dcy+803WCbuZQxZkHJabtzyY7oJzCuA==")' 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html#commentform">引用</A>&nbsp;&nbsp;<A 
            title=查看该作者发表过的评论 
            href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=%e4%b8%80%e7%9e%ac%e9%97%b4" 
            target=_blank>查看</A>&nbsp;&nbsp;<A 
            id=Comments1_CommentList_ctl01_DeleteLink 
            href="javascript:__doPostBack('Comments1$CommentList$ctl01$DeleteLink','')"></A>&nbsp;&nbsp;<A 
            id=Comments1_CommentList_ctl01_EditLink></A> </DIV>
            <DIV class=comment_content><SPAN class=blog_comment_body 
            id=comment_body_1115763>有2个地方不太懂 <BR>1. 
            <BR>用NavigationWindow的时候，尽量Update the client area by object,而不是URI， 
            <BR>2.数据绑定1说的A和C两种情况。能否举个例子。谢谢</SPAN></DIV>
            <DIV class=comment_footer><A id=Comments1_CommentList_ctl01_NameLink 
            href="http://www.cnblogs.com/gowhere/" target=_blank>一瞬间</A>&nbsp;<A 
            class=sendMsg2This title=给此人发送站内短消息 
            href="http://space.cnblogs.com/msg/send/ä¸ç¬é´">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</A> 
            评论于 2008-03-21 09:48</DIV></DIV></DIV></DIV></DIV>
            <DIV class=seperator>&nbsp;</DIV>
            <SCRIPT type=text/javascript>
    var commentAuthorHasChecked = false;
    var commentAuthorIsValid = false;
    var commentUrlIsValid = true;
    var commentEmailIsValid = true;
    var authenCodeHasChecked = false;
    var authenCodeIsValid = true;
    var hasLogined = false;
    
    function PostComment() {    
        
        var isValid = true;
        
        if($("#wrapAuthenCode").css("display")=="none"){
            ShowAuthenCode();
            $("#tip_AuthenCode").css("color","red");
            $("#tip_AuthenCode").html("请输入验证码！");
            isValid = false;
        }
        
        if(!hasLogined && !commentAuthorHasChecked){
            CheckAuthor();        
        }                
        if(!hasLogined && !commentAuthorIsValid){
            isValid = false;
        }
                       
        if(!authenCodeHasChecked){
            CheckAuthenCode();            
        }
        if(!authenCodeIsValid){
            isValid = false;
        }
        
        if(!hasLogined && !commentUrlIsValid){            
            isValid = false;
        }        
        if(!commentEmailIsValid){            
            isValid = false;
        }        
        if(!CheckCommentContent()){
            isValid = false;
        }    
        if(!isValid){
            return;
        }

        var content = $("#tbCommentBody").val();
        if(content.length>2000){
            alert("评论内容过长！不允许发布！");
            return;
        }     
        
        if(content.indexOf("　Ｅ　　　　　　　　　Ｅ　　　　　　　　　　Ｅ　　　　　　")>=0){
            alert("该内容不允许布！");
            return;
        }   
        
       if ($("#span_comment_posted").html()!='' && $("#span_comment_posted").html()==content){
            alert("该评论已发表过!");
            return;
        }
        
        $("#tip_comment").html("评论提交中...");
        $("#span_comment_posted").html(content);
        //content = content.replace("'", "\\'");
        var email = $("#tbCommentEmail").val();
        var authenNum = $("#tbAuthenCode").val();
        var authenId = $("#span_comment_test").html();
        var comment = {};
        comment.authenNum = authenNum;
        comment.authenId= authenId;
        comment.parentId = 0;
        comment.blogId = 0;
        comment.sourceUrl = '';
        comment.author = $("#tbCommentAuthor").val();
        comment.url = $("#tbCommentAuthorUrl").val();
        comment.authenCode = $("#tbAuthenCode").val();
        comment.email = email;
        comment.title = '';
        comment.content = content;
        comment.parentCommentId = $("#span_parentcomment_id").html();
        $.ajax({
            url: '/ws/CommentService.asmx/AddAnonymousComment',
            data: $.toJSON(comment),
            type: "post",
            dataType: "json",
            contentType: "application/json; charset=utf8",
            success: function(data) {
               if (data.d["IsSuccess"]) {
                    ShowCommentMsg("感谢您的回复:)");
                    //RereshComments2(comment.parentId);
                    $("#tbCommentBody").val('');
                    //$("#divCommentShow").html(data.d["ReturnData"]+content.replace(/\n/g,"<br/>")+"<br/><br/>");
                    $("#divCommentShow").html($("#divCommentShow").html()+data.d["ReturnData"]); 
                    $("#tip_AuthenCode").html('');
                    RefreshAuthenCode();
                    $("#tbAuthenCode").val("");                    
                    CommentNotify(data.d["CommentID"]);
                }
                else {
                    ShowCommentMsg(data.d["ReturnData"]);//"抱歉！评论提交失败！请与管理员联系。");
                    $("#span_comment_posted").html(''); 
                }
            },
            error: function(xhr) {
                ShowCommentMsg("抱歉！评论提交失败！请与管理员联系。");
                $("#span_comment_posted").html('');  
                //alert(xhr.responseText);
            }
        }
        );
    }
    
    function RefreshAuthenCode(){
        AjaxPost("/ws/CommentService.asmx/RefreshAuthenCode","{}",RefreshImg); 
        $("#lnkRereshAuthenCode").html("<span style='color:red'>刷新中...</span>");
        return false;
    }
    
    function RefreshImg(response){
       $("#imgAuthenCode").attr("src","/Modules/CaptchaImage/ValidCodeImage.aspx?id="+encodeURIComponent(response));
       $("#span_comment_test").html(response);
       $("#lnkRereshAuthenCode").html("看不清，换一个");
    }
    
    function ShowAuthenCode(){
        //if($("#wrapAuthenCode").css("display")=="none"){    
        //    AjaxPost("/ws/CommentService.asmx/RefreshAuthenCode","{}",ShowAuthenCodeOk);
        //}
        $("#wrapAuthenCode").show();      
    }
    
    function ShowAuthenCodeOk(response){
         UpdateAuthenCode();
         $("#tbAuthenCode").val("");
         $("#wrapAuthenCode").show();
         $("#tip_AuthenCode").html('');
    }  
 
    
    function CheckAuthor(isOnblur){
        commentAuthorHasChecked = true;
        var maxLength = 30;
        if($("#tbCommentAuthor").val().length == 0){
            $("#tip_author").html("请输入您的昵称！");
            commentAuthorIsValid = false;
            return false;
        }     
        else if($("#tbCommentAuthor").val().length > maxLength){
            $("#tip_author").html("昵称不允许超过" + maxLength + "个字符！");
            commentAuthorIsValid = false;
            return false;
        }
        else{
            //if(isOnblur){
                AjaxPost("/ws/CommentService.asmx/IsAuthorExist","{author:'"+$("#tbCommentAuthor").val()+"'}" ,OnCheckAuthorExist);
            //}
            //else{
            //    $("#tip_author").html("");
            //    commentAuthorIsValid = true;
            //}
            return true;
        }
   }
   
    function OnCheckAuthorExist(response){        
        if(!response){
            $("#tip_author").html("");
            commentAuthorIsValid = true;
        }
        else{
            $("#tip_author").html("该昵称已被使用，请更换昵称");
            commentAuthorIsValid = false;
        }
   }
   
    function CheckUrl(){
        var maxLength = 50;
        var url = $("#tbCommentAuthorUrl").val();
        
        if(url.length == 0){
            commentUrlIsValid = true;
            return true;
        }
        else if(url.length > maxLength){
            $("#tip_url").html("主页地址不允许超过" + maxLength + "个字符！");
            commentUrlIsValid = false;
            return false;
        }
        else if(url.indexOf("http://")!=0 || url.indexOf(".") < 0){
            $("#tip_url").html("主页地址要以“http://”开头");
            commentUrlIsValid = false;
            return false;
        }
        else{
            $("#tip_url").html("");
            commentUrlIsValid = true;
            return true;
        }
   }
   
   function CheckEmail(){
        var email = $("#tbCommentEmail").val();
        if(email.length>0){
            var regExp = new RegExp("\\w+@((\\w|\-)+\\.)+[a-z]{2,3}");
            if(!regExp.test(email)){
                $("#tip_email").html("请输入正确的邮件地址!");
                commentEmailIsValid = false;
            }
            else{
                commentEmailIsValid = true;
                 $("#tip_email").html("");
            }
        }
        else{
            commentEmailIsValid = true;
            $("#tip_email").html("");  
        }
   }
   
   function CheckAuthenCode(){
        authenCodeHasChecked = true;
        var num = $("#tbAuthenCode").val();
        var id = $("#span_comment_test").html();
        $("#tip_AuthenCode").css("color","red");
        if(num.length==0){
             authenCodeIsValid = false;
             $("#tip_AuthenCode").html("请输入验证码！");
             return;
        }
        else if(num.length!=4){
            authenCodeIsValid = false;
            $("#tip_AuthenCode").html("请输入四位数字！");
             return;
        }
        else if(new RegExp("(\d+)").test(num)){
            authenCodeIsValid = false;
            $("#tip_AuthenCode").html("请输入四位数字！");
             return;
        }
        else{
            AjaxPost("/ws/CommentService.asmx/CheckAuthenCode","{number:"+num+",id:'"+id+"'}", OnCheckAuthenCode);
        }
   }
   
   function OnCheckAuthenCode(response){
        if(response){
            $("#tip_AuthenCode").css("color","green");
            $("#tip_AuthenCode").html("验证码输入正确！");
            authenCodeIsValid = true;            
        }
        else{
            $("#tip_AuthenCode").css("color","red");
            $("#tip_AuthenCode").html("验证码输错啦！");
            RefreshAuthenCode();
            authenCodeIsValid = false;           
        }
   }
   
   function CheckCommentContent(){
    if($("#tbCommentBody").val().length==0){
        alert("请输入评论内容！");
        return false;
    }
    return true;
   }
    
</SCRIPT>

            <DIV class=commentform id=ctl04_comment_form>
            <DIV id=ctl04_divLoginPannel>
            <DIV class=login_tips>注册用户登录后才能发表评论，请<A 
            href="http://passport.cnblogs.com/login.aspx?ReturnUrl=http%3a%2f%2fwww.cnblogs.com%2fyzlhccdec%2farchive%2f2008%2f03%2f20%2f1114161.html%3flogin%3d1%23commentform">登录</A>或<A 
            href="http://passport.cnblogs.com/register.aspx?ReturnUrl=http%3a%2f%2fwww.cnblogs.com%2fyzlhccdec%2farchive%2f2008%2f03%2f20%2f1114161.html%23Bottom2">注册</A>。</DIV></DIV>
            <DIV class=c_ad_block id=ad_under_comment>
            <SCRIPT type=text/javascript>
    try {
        GA_googleFillSlot("cnblogs_blogpost_bottom");
    }
    catch (e) { }
</SCRIPT>
            </DIV>
            <DIV class=c_ad_block id=site_nav_under>网站导航：<BR><A 
            href="http://www.cnblogs.com/" target=_blank>博客园首页</A> &nbsp;<A 
            href="http://news.cnblogs.com/" target=_blank>IT新闻</A> &nbsp;<A 
            href="http://home.cnblogs.com/" target=_blank>个人主页</A> &nbsp;<A 
            href="http://home.cnblogs.com/ing/" target=_blank>闪存</A> &nbsp;<A 
            href="http://job.cnblogs.com/" target=_blank>程序员招聘</A> &nbsp;<A 
            href="http://space.cnblogs.com/" target=_blank>社区</A> &nbsp;<A 
            href="http://space.cnblogs.com/q/" target=_blank>博问</A> &nbsp;<A 
            href="http://wz.cnblogs.com/" target=_blank>网摘</A> </DIV>
            <DIV class="itnews c_ad_block" id=itnews>IT新闻:<BR>· <A 
            href="http://news.cnblogs.com/n/54382/" 
            target=_blank>周鸿祎：好的互联网产品是运营出来的</A><BR>· <A 
            href="http://news.cnblogs.com/n/54380/" target=_blank>女性创业潮涌中国 
            成经济增长“隐形发动机”</A><BR>· <A href="http://news.cnblogs.com/n/54379/" 
            target=_blank>手机浏览器成竞争新焦点 国内市场呈现三大阵营</A><BR>· <A 
            href="http://news.cnblogs.com/n/54378/" 
            target=_blank>McAfee报告称中国是第三大网络不安全国家</A><BR>· <A 
            href="http://news.cnblogs.com/n/54377/" 
            target=_blank>谷歌官方博客阐述推出Nexus One智能手机原因</A><BR></DIV>
            <DIV class=c_ad_block id=ad_under_comment2><A 
            href="http://www.china-pub.com/STATIC07/0912/zh_ndcx_091212.asp" 
            target=_blank><IMG 
            style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" 
            alt="" 
            src="WPF性能校调 - Yzl的研究室 - 博客园.files/chinapub_20091222.jpg"></A><BR><A 
            href="http://www.china-pub.com/itbook/" target=_blank>China-pub 
            计算机图书网上专卖店！6.5万品种2-8折！</A><BR><A 
            href="http://www.china-pub.com/static07/0901/zh_jueba_090121.asp" 
            target=_blank>China-Pub 计算机绝版图书按需印刷服务</A><BR></DIV>
            <DIV class=c_ad_block id=div_commentbox_nav>链接：<A 
            href="http://www.cnblogs.com/yzlhccdec/archive/2008/03/20/1114161.html?switchskin=1#skinlist">切换模板</A><BR></DIV>
            <DIV id=relative_search><BR><B>相关搜索:</B><BR><A 
            href="http://zzk.cnblogs.com/s?w=WPF+SilverLight" target=_blank>WPF 
            SilverLight</A> <A 
            href="http://zzk.cnblogs.com/s?w=%5b.NET%5dWPF%2fSilverLight" 
            target=_blank>[.NET]WPF/SilverLight</A> </DIV>
            <DIV id=relative_search><BR><B>在知识库中查看：</B><BR><A 
            href="http://kb.cnblogs.com/a/1114161/">WPF性能校调</A></DIV></DIV></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM>
<SCRIPT src="WPF性能校调 - Yzl的研究室 - 博客园.files/shCore.js" 
type=text/javascript></SCRIPT>

<SCRIPT src="WPF性能校调 - Yzl的研究室 - 博客园.files/shLanguage.js" 
type=text/javascript></SCRIPT>

<SCRIPT type=text/javascript>
        try {
            SyntaxHighlighter.config.clipboardSwf = 'http://common.cnblogs.com/flash/clipboard.swf'
            SyntaxHighlighter.all();
        } catch (e) { }
    </SCRIPT>

<SCRIPT src="WPF性能校调 - Yzl的研究室 - 博客园.files/ShowHidden.js" 
type=text/javascript></SCRIPT>

<SCRIPT type=text/javascript>
        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </SCRIPT>

<SCRIPT type=text/javascript>
        try {
            var pageTracker = _gat._getTracker("UA-476124-1");
            pageTracker._trackPageview();
        } catch (err) { }</SCRIPT>
</BODY></HTML>
